﻿<UserControl x:Class="MouseExtender.Controls.UserControls.LauncherItemUC"
						 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
						 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
						 xmlns:common="clr-namespace:MouseExtender.Logic.Common"
						 xmlns:local="clr-namespace:MouseExtender.Controls.UserControls"
						 xmlns:resx="clr-namespace:MouseExtender.Resources"
						 MouseEnter="UserControl_MouseEnter" MouseLeave="UserControl_MouseLeave" MouseMove="UserControl_MouseMove" 
                         PreviewMouseLeftButtonDown="UserControl_PreviewMouseLeftButtonDown" 
                         PreviewMouseUp="UserControl_PreviewMouseUp" >
    <UserControl.Resources>
        <Storyboard x:Key="sbMoveItem" Name="sbMoveItem" Duration="00:00:00.45" Storyboard.TargetName="dragTransform" Completed="sbMoveItem_Completed">
            <DoubleAnimationUsingKeyFrames Name="xAnimation" BeginTime="00:00:00" Storyboard.TargetProperty="X" >
                <SplineDoubleKeyFrame KeyTime="00:00:00.45" Value="0" KeySpline="0.5,0,0.5,1"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Name="yAnimation" BeginTime="00:00:00" Storyboard.TargetProperty="Y" >
                <SplineDoubleKeyFrame KeyTime="00:00:00.45" Value="0" KeySpline="0.5,0,0.5,1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>
    <UserControl.RenderTransform>
        <TranslateTransform x:Name="dragTransform" X="0" Y="0"></TranslateTransform>
    </UserControl.RenderTransform>
    <UserControl.ContextMenu>
        <ContextMenu x:Name="contextMenu">
            <MenuItem Command="common:Commands.EditItem" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Parent.PlacementTarget}"/>
            <MenuItem Command="common:Commands.Delete" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=Parent.PlacementTarget}"/>
            <MenuItem x:Name="sendTo" Header="{x:Static resx:UIResources.Command_SendToTab}">
                <MenuItem.ItemTemplate>
                    <DataTemplate>
                        <MenuItem Header="{Binding Path=Name}" Command="common:Commands.SendToAnotherTab" CommandParameter="{Binding RelativeSource={RelativeSource Self}}"/>
                    </DataTemplate>
                </MenuItem.ItemTemplate>
            </MenuItem>
            <Separator/>
            <MenuItem Command="common:Commands.AddFile"/>
            <MenuItem Command="common:Commands.AddFolder"/>
            <MenuItem Command="common:Commands.AddUrl"/>
            <MenuItem Command="common:Commands.AddRunningProgram"/>
            <MenuItem Command="common:Commands.AddTab"/>
            <Separator/>
            <MenuItem Command="common:Commands.Disable" x:Name="miDisable"/>
            <MenuItem Command="common:Commands.ShowSettings"/>
            <MenuItem Command="common:Commands.CheckUpdates"/>
            <MenuItem Command="common:Commands.About"/>
            <MenuItem Command="common:Commands.Exit"/>
        </ContextMenu>
    </UserControl.ContextMenu>
    <Button x:Name="itemButton" Click="Button_Click" Focusable="False" Height="42" Width="42" Margin="4"
            BitmapEffect="{Binding Source={StaticResource softwareItemShadowEffect}, Converter={StaticResource SettingsToEffectConverter}, ConverterParameter=software}"
            Effect="{Binding Source={StaticResource hardwareItemShadowEffect}, Converter={StaticResource SettingsToEffectConverter}, ConverterParameter=hardware}"
            ToolTipService.InitialShowDelay="1000">
        <Button.Triggers>
            <EventTrigger RoutedEvent="Border.MouseEnter">
                <BeginStoryboard>
                    <Storyboard Timeline.DesiredFrameRate="{StaticResource ResourceKey=animationFrameRate}">
                        <ColorAnimation x:Name="firstStopAnimation" Storyboard.TargetName="firstStop" Storyboard.TargetProperty="Color" Duration="0:0:0" To="#FF072B3B"/>
                        <ColorAnimation x:Name="secondStopAnimation" Storyboard.TargetName="secondStop" Storyboard.TargetProperty="Color" Duration="0:0:0" To="#FF157097"/>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
            <EventTrigger RoutedEvent="Border.MouseLeave">
                <BeginStoryboard>
                    <Storyboard Timeline.DesiredFrameRate="{StaticResource ResourceKey=animationFrameRate}">
                        <ColorAnimation Storyboard.TargetName="firstStop" Storyboard.TargetProperty="Color" Duration="0:0:0.3" To="#FF000000"/>
                        <ColorAnimation Storyboard.TargetName="secondStop" Storyboard.TargetProperty="Color" Duration="0:0:0.3" To="#FF4C4C4C"/>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Button.Triggers>
        <Button.Template>
            <ControlTemplate>
                <ContentPresenter 
                    RecognizesAccessKey="True" 
                    Content="{TemplateBinding ContentControl.Content}" 
                    ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" 
                    HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" 
                    VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" 
                    SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
            </ControlTemplate>
        </Button.Template>
        <Button.ToolTip>
            <ToolTip x:Name="toolTip" Placement="Bottom"/>
        </Button.ToolTip>
        <Canvas x:Name="iconPlaceholder" Width="42" Height="42">
            <Canvas.Clip>
                <RectangleGeometry Rect="-1,-1 44,44" RadiusX="8.5" RadiusY="8.5"/>
            </Canvas.Clip>
            <Canvas.Background>
                <DrawingBrush Stretch="Fill">
                    <DrawingBrush.Drawing>
                        <GeometryDrawing>
                            <GeometryDrawing.Brush>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <GradientStop x:Name="firstStop" Color="#FF000000" Offset="0.5"/>
                                    <GradientStop x:Name="secondStop" Color="#FF4C4C4C" Offset="1"/>
                                </LinearGradientBrush>
                            </GeometryDrawing.Brush>
                            <GeometryDrawing.Geometry>
                                <RectangleGeometry Rect="0,0 42,42" RadiusX="8" RadiusY="8"/>
                            </GeometryDrawing.Geometry>
                        </GeometryDrawing>
                    </DrawingBrush.Drawing>
                </DrawingBrush>
            </Canvas.Background>
            <Image Name="imgIcon" Margin="5" Panel.ZIndex="1"/>
            <Path Name="glare" Stretch="Fill" Fill="#33FFFFFF" Panel.ZIndex="2" Data="M 8,0 H 34 A 8,8 0 0,1 42,8 V 21 A 150, 150 0 0,1 0,21 V 8 A 8,8 0 0,1 8,0"/>
        </Canvas>
    </Button>
</UserControl>